package com.logic.saas.util;

/**
 * 定义所有mysql执行sql期间出错信息代码与错误信息的对应关系
 * code 参考sql-error-codes.xml
 * @author jeffdong
 *
 */
public class SqlErrorCodesUtil {

	public static String getErrorMsgByCode(int errorCode){
		String errorMsg = "error.sql.unknow_error";
		
		switch(errorCode){
			case 1054: errorMsg = "error.sql.badSqlGrammar";break;
			case 1064: errorMsg = "error.sql.badSqlGrammar";break;
			case 1146: errorMsg = "error.sql.badSqlGrammar";break;
			
			case 1062: errorMsg = "error.sql.duplicateKey";break;
			
			case 630: errorMsg = "error.sql.dataIntegrityViolation";break;
			case 839: errorMsg = "error.sql.dataIntegrityViolation";break;
			case 840: errorMsg = "error.sql.dataIntegrityViolation";break;
			case 893: errorMsg = "error.sql.dataIntegrityViolation";break;
			case 1169: errorMsg = "error.sql.dataIntegrityViolation";break;
			case 1215: errorMsg = "error.sql.dataIntegrityViolation";break;
			case 1216: errorMsg = "error.sql.dataIntegrityViolation";break;
			case 1217: errorMsg = "error.sql.dataIntegrityViolation";break;
			case 1451: errorMsg = "error.sql.dataIntegrityViolation";break;
			case 1452: errorMsg = "error.sql.dataIntegrityViolation";break;
			case 1557: errorMsg = "error.sql.dataIntegrityViolation";break;
			
			case 1: errorMsg = "error.sql.dataAccessResourceFailure";break;
			case 1205: errorMsg = "error.sql.cannotAcquireLock";break;
			case 1213: errorMsg = "error.sql.deadlockLoser";break;
			default:errorMsg = "error.sql.unknow_error";break;
		}
		
		return errorMsg;
	}
}
